<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            position: absolute;
            /* top:2px; */
        }

    </style>
</head>
<body>
    <img src="../../code/图片/5.jpg" alt="">
    <script>
        var pic=document.querySelector('img');
        document.addEventListener('mousemove',function(e){
            //1.mousemove只要鼠标移动1px就会触发事件
            var x=e.pageX;
            var y=e.pageY;
            // 3.千万不要忘记加单位
            pic.style.left=x+'px';
            pic.style.top=y+'px';
        })
    </script>
</body>
</html>